package com.jf.ajax.service;

import com.jf.ajax.dao.UserDAO;
import com.jf.ajax.domain.User;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2024-09-13
 * Time:21:26
 */
public class UserService {
    private final UserDAO userDAO = new UserDAO();
    public User getUserById(int id) {
        return userDAO.querySingle("select * from `user` where id=?", id);
    }
    public User getUserByUsername(String username) {
        return userDAO.querySingle("select * from `user` where `name`=?", username);
    }
    public int addUser(User user) {
        return userDAO.update("insert into `user` values(null, ?, ?, ?)", user.getName(), user.getPassword(), user.getEmail());
    }
}
